package com.jf.concurrent.queue.demo;

import lombok.extern.slf4j.Slf4j;

import static java.lang.System.out;
import static java.lang.Thread.currentThread;

/**
 * 消费者
 *
 * @author Junfeng
 */
@Slf4j
public class Consumer implements Runnable {
    private Topic topic;

    public Consumer(Topic topic) {
        this.topic = topic;
    }


    @Override
    public void run() {
        while (Controller.FLAG) {
            Object poll = topic.poll();
            out.println(currentThread().getName() + "\t  消费了 " + poll);
        }
        out.println(currentThread().getName() + "\t 停止消费");
    }
}
